import { createTransmitter } from './ElementProxyTransmitter.js'
export function initWorker(canvas) {
  canvas.focus()
  const worker = new Worker('/three/ev/worker/worker-entrance.js', {
    type: 'module'
  })

  // TODO 考虑将 里面的事件函数提取出来
  createTransmitter(canvas, worker)
  const offscreen = canvas.transferControlToOffscreen()

  worker.postMessage(
    {
      type: 'start',
      canvas: offscreen
    },
    [offscreen]
  )
  return worker
}
